/**   
* @Title: WebXssFilter.java
* @Package org.xaoyaoyao.cloud.web.filter
* @Description: TODO
* @author xaoyaoyao
* @date Feb 11, 2019 2:29:43 PM
* @version V1.0   
*/
package org.xaoyaoyao.cloud.web.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: WebXssFilter
 * @Description: TODO
 * @author xaoyaoyao
 * @date Feb 11, 2019 2:29:43 PM
 * 
 */
@Slf4j
@WebFilter(filterName = "webXssFilter", urlPatterns = "/*")
public class WebXssFilter implements Filter {

	FilterConfig filterConfig = null;

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		log.info(">>>>>>>> WebXssFilter init");
		this.filterConfig = filterConfig;
	}

	@Override
	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
		log.info(">>>>>>>> WebXssFilter doFilter");
		filterChain.doFilter(new XssHttpServletRequestWrapper((HttpServletRequest) servletRequest), servletResponse);
	}

	@Override
	public void destroy() {
		log.info(">>>>>>>> WebXssFilter destroy");
		this.filterConfig = null;
	}
}
